package com.ckh.springboot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ckh.springboot.entity.HomeWorkStudent;
import com.ckh.springboot.mapper.HomeWorkStudentMapper;
import com.ckh.springboot.service.IHomeWorkStudentService;
import lombok.Setter;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class IHomeWorkStudentServiceImpl extends ServiceImpl<HomeWorkStudentMapper, HomeWorkStudent>  implements IHomeWorkStudentService {
    @Resource HomeWorkStudentMapper homeWorkStudentMapper;
    @Override
    public List<HomeWorkStudent> getHomeWorkStudentList(Integer id) {
        return homeWorkStudentMapper.getHomeWorkTeacherList(id);
    }
    @Override
    public List<HomeWorkStudent> getHomeWorkStudentListByStudentId(String studentId) {
        QueryWrapper<HomeWorkStudent> wrapper = new QueryWrapper<>();
        wrapper.eq("student_id", studentId);
        return this.list(wrapper);
    }
    @Override
    public int deleteHomeWorkStudentList(Integer id ,Integer studentId) {
        return homeWorkStudentMapper.deleteHomeWorkTeacherList(id ,studentId);
    }

    @Override
    public int updateHomeWorkStudentList(Integer id , String score ,  Integer studentId) {
        return homeWorkStudentMapper.updateHomeWorkTeacherList(id , score ,studentId );
    }

    @Override
    public int uploadHomeWork(Integer id, String text, String image , String name , Integer studentId) {
        Date date = new Date();
        return homeWorkStudentMapper.uploadHomeWork(id , text, image , name , studentId ,date);
    }

    @Override
    public List<HomeWorkStudent> getStudentHomeWorkDetail(Integer id, Integer homeId) {
        return homeWorkStudentMapper.getStudentHomeWorkDetail(id,homeId) ;
    }

    @Override
    public int addScore(Integer id, Integer homeId, String score) {
        return  homeWorkStudentMapper.addScore(id , homeId, score);
    }

    @Override
    public List<HomeWorkStudent> getDoneHomeWorkStudent(Integer homeId) {
        return homeWorkStudentMapper.getDoneHomeWorkStudent(homeId);
    }
}
